<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>折叠搜索栏</title>
    <link rel="stylesheet" type="text/css" href="iconfont.css" />
    <style>
      body {
        margin: 0;
        padding: 0;
        background: orange;
      }
      a {
        text-decoration: none;
      }
      .main {
        position: absolute;
        top: 50%;
        left: 50%;
        background: #34495e;
        transform: translate(-50%, -50%);
        height: 40px;
        border-radius: 40px;
        padding: 10px;
      }
      .main:hover .txt {
        width: 240px;
        padding: 0 6px;
      }
      .btn {
        color: #e67e22;
        float: right;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #34495e;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: 0.6s;
      }
      .txt:focus {
        width: 240px;
        padding: 0 6px;
      }
      .main:hover .btn {
        background: #fff;
      }
      .txt {
        border: none;
        background: none;
        outline: none;
        float: left;
        padding: 0;
        color: #fff;
        font-size: 16px;
        transition: 0.6s;
        line-height: 40px;
        width: 0px;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div class="main">
      <input type="text" name="" placeholder="请输入查找内容" class="txt" />
      <a href="" class="btn">
        <i class="iconfont icon-chazhao"></i>
      </a>
    </div>
  </body>
</html>
